package com.策略模式;

/**
 * 税策略
 * @author Fang Ruichuan
 * @date 2022-09-28 10:48
 */
public interface TaxStrategy {
    double calc(long amount);
}

class InterTaxStrategy implements TaxStrategy {

    @Override
    public double calc(long amount) {
        System.out.println("内税计算中");
        // 获取税率
        final double taxRate = 0.2;
        return amount * taxRate;
    }
}


class OuterTaxStrategy implements TaxStrategy {

    @Override
    public double calc(long amount) {
        System.out.println("外税计算中");
        // 获取税率
        final double taxRate = 0.2;
        return amount / (1 + taxRate) * taxRate;
    }
}

// 税类型定义
enum TaxType {
    INTER, OUTER
}